using UnityEngine;
using System.Collections;

public class DemoTwoMono : MonoBehaviour {
    ThreadDemoTwo meep;

    public float speed = 10;

	// Use this for initialization
	void Start () {
        meep = new ThreadDemoTwo();

        System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(meep.Run));
        t.Start();
	
	}
	
	// Update is called once per frame
	void Update () {

        transform.position = transform.position + (speed * Time.deltaTime) * new Vector3(1, 0, 0);

        meep.target = transform.position;

        if (Input.GetKeyDown(KeyCode.Space))
        {
            meep.run = false;
        }
	}

    public void OnDestroy()
    {
        meep.run = false;
    }
}
